/*
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package botobjects;

import input.IRCCommand;
import interfaces.BotObject;
import interfaces.CalculableUtopiaEntity;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * A class that represents a science category
 * 
 * 
 */
public class Science implements BotObject, CalculableUtopiaEntity {
   private String name = "";
   private String formula = "";
   private final String[] cap = { "0" };
   private String syntax = "";
   private String result = "";

   public Science(final String name, final String formula, final String syntax, final String result) {
	  this.name = name;
	  this.formula = formula;
	  this.syntax = syntax;
	  this.result = result;
   }

   @Override
   public String[] getCap() {
	  return cap;
   }

   @Override
   public String[] getFormula(final IRCCommand command) {
	  String temp = formula;
	  final String[] split = syntax.split(" ");
	  if (split.length != command.size() - 2)
		 return null;
	  for (int i = 0; i < split.length; ++i) {
		 temp = temp.replace(split[i], command.get(i + 2));
	  }
	  final String[] out = { temp };
	  return out;
   }

   @Override
   public List<String> getIRCOutput(final int outputType, final String... args) {
	  return new LinkedList<String>();
   }

   @Override
   public String getName() {
	  return name;
   }

   @Override
   public String[] getResult() {
	  if ("".equals(result))
		 return null;
	  final String[] out = { result };
	  return out;
   }

   @Override
   public Map<String, Object> getRPCOutput(final int... includes) {
	  return new HashMap<String, Object>();
   }

   @Override
   public boolean saveToDB() {
	  // not used
	  return false;
   }
}
